package com.gilight.base.controller.uiapp;

import com.gilight.base.admin.groupshopad.GroupshopAdService;
import com.gilight.base.base.ResultEntity;
import com.gilight.base.base.exception.ServiceException;
import com.gilight.base.uiapp.category.CategoryService;
import com.gilight.base.uiapp.zzjg.ZzjgService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author liken
 * 商品管理控制类
 */
@RestController
@RequestMapping("/web/app-zzjg")
public class AppZZJGController {

    @Autowired
    private CategoryService categoryService;
    @Autowired
    private ZzjgService zzjgService;
    @Autowired
    private GroupshopAdService groupshopAdService;


    /**
     *
     * @return
     */
    @ApiOperation(value = "根据用户当前经纬度获取所有部门最近距离排序")
    @RequestMapping(value = "/zzjg-list", method = {RequestMethod.GET})
    public ResultEntity zzjgList(Float lat,Float lng,String sheng,String shi,String quxian,String jiedao,Long brandId) {
        ResultEntity resultEntity = new ResultEntity();

        resultEntity.setData(zzjgService.getZzjgByWEIDU(lat,lng,sheng,shi,quxian,jiedao,brandId));
        return resultEntity;
    }

    @ApiOperation(value = "创建")
    @RequestMapping(value = "/get-category-family")
    public ResultEntity getCategoryFamily(Long categoryId) {
        ResultEntity resultEntity = new ResultEntity();

        try {
            resultEntity.setData(categoryService.getCategoryFamily(categoryId));
        } catch (ServiceException e) {
            e.printStackTrace();
        };
        return resultEntity;
    }
    @ApiOperation(value = "获取企业团餐")
    @RequestMapping(value = "/get-good-dinner-shop")
    public ResultEntity getGoodDinnerGroup(Long zzjgId) {
        ResultEntity resultEntity = new ResultEntity();
        resultEntity.setData(groupshopAdService.getGoodDinnerGroup(zzjgId));
        return resultEntity;
    }
}
